package com.ellfors.module_first.snap

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.LinearSnapHelper
import androidx.recyclerview.widget.RecyclerView
import com.ellfors.common.base.BaseActivity
import com.ellfors.common.base.EmptyViewModel
import com.ellfors.module_first.databinding.ActivitySnapBinding

/**
 * 测试SnapHelper（RecyclerView滚动相关的帮助类）
 */
class SnapActivity : BaseActivity<ActivitySnapBinding, EmptyViewModel>() {

    companion object {
        fun start(activity: AppCompatActivity) {
            activity.startActivity(Intent(activity, SnapActivity::class.java))
        }
    }

    override fun initView() {
        showTitleBar("测试SnapHelper")

        mBinding.rcvTest.layoutManager = LinearLayoutManager(
            this, RecyclerView.HORIZONTAL, false
        )
        mBinding.rcvTest.adapter = SnapAdapter()

        val snap = LinearSnapHelper()
        snap.attachToRecyclerView(mBinding.rcvTest)

        mBinding.rcvTest2.layoutManager = LinearLayoutManager(
            this, RecyclerView.HORIZONTAL, false
        )
        mBinding.rcvTest2.adapter = SnapAdapter()

        val snap2 = StartLinearSnapHelper()
        snap2.attachToRecyclerView(mBinding.rcvTest2)
    }

    override fun initData() {

    }
}